|
|
|
|
|
|
|
Listing 20.3. The Visual Basic code to make a replica. |
|
|
|
|
|
|
|
|
Private Sub cmdMakeReplica_Click()
Dim dbMaster As Database
'Open the database in exclusive mode
Set dbMaster = OpenDatabase("c:\tysdbvb5\source\data\replmast.mdb", True)
dbMaster.MakeReplica "c:\tysdbvb5\source\data\copy.mdb", "Replica of " &
"dbMaster"
dbMaster.Close
MsgBox "You have created a copy of your database"
End Sub |
|
|
|
|
|
|
|
|
This code first opens the database REPLMAST.MDB (our Design Master), and then uses the MakeReplica method to create a new member of the replica set named COPY.MDB. |
|
|
|
|
| |
|
|
|
|
Create the COPY.MDB file only once. Trying to create another replica named COPY.MDB causes the program to fail. |
|
|
|
|
|
|
| |
|
|
|
|
Always make a backup copy of a database before you create a replica. This should be done whether you are creating a copy of the Design Master, or another replica. |
|
|
|
|
|
|
|
|
|
|
Save your project and execute it. Select the Make Replica button to create the new database. |
|
|
|
|
| |
|
|
|
|
You can't depend on the traditional backup and restore methodology to safeguard a Design Master. Changes occur to the Design Master during the synchronization process. Restoring a backup from a tape drive might insert a database that is out of synch, and that might not be able to perform synchronization with other members of the replica set. It is a far better practice to use replication to create a backup copy that can be made the Design Master in case the original is corrupted. |
|
|
|
|
|
|
|